{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 分类"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、鸢尾花数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data': array([[5.1, 3.5, 1.4, 0.2],\n",
       "        [4.9, 3. , 1.4, 0.2],\n",
       "        [4.7, 3.2, 1.3, 0.2],\n",
       "        [4.6, 3.1, 1.5, 0.2],\n",
       "        [5. , 3.6, 1.4, 0.2],\n",
       "        [5.4, 3.9, 1.7, 0.4],\n",
       "        [4.6, 3.4, 1.4, 0.3],\n",
       "        [5. , 3.4, 1.5, 0.2],\n",
       "        [4.4, 2.9, 1.4, 0.2],\n",
       "        [4.9, 3.1, 1.5, 0.1],\n",
       "        [5.4, 3.7, 1.5, 0.2],\n",
       "        [4.8, 3.4, 1.6, 0.2],\n",
       "        [4.8, 3. , 1.4, 0.1],\n",
       "        [4.3, 3. , 1.1, 0.1],\n",
       "        [5.8, 4. , 1.2, 0.2],\n",
       "        [5.7, 4.4, 1.5, 0.4],\n",
       "        [5.4, 3.9, 1.3, 0.4],\n",
       "        [5.1, 3.5, 1.4, 0.3],\n",
       "        [5.7, 3.8, 1.7, 0.3],\n",
       "        [5.1, 3.8, 1.5, 0.3],\n",
       "        [5.4, 3.4, 1.7, 0.2],\n",
       "        [5.1, 3.7, 1.5, 0.4],\n",
       "        [4.6, 3.6, 1. , 0.2],\n",
       "        [5.1, 3.3, 1.7, 0.5],\n",
       "        [4.8, 3.4, 1.9, 0.2],\n",
       "        [5. , 3. , 1.6, 0.2],\n",
       "        [5. , 3.4, 1.6, 0.4],\n",
       "        [5.2, 3.5, 1.5, 0.2],\n",
       "        [5.2, 3.4, 1.4, 0.2],\n",
       "        [4.7, 3.2, 1.6, 0.2],\n",
       "        [4.8, 3.1, 1.6, 0.2],\n",
       "        [5.4, 3.4, 1.5, 0.4],\n",
       "        [5.2, 4.1, 1.5, 0.1],\n",
       "        [5.5, 4.2, 1.4, 0.2],\n",
       "        [4.9, 3.1, 1.5, 0.2],\n",
       "        [5. , 3.2, 1.2, 0.2],\n",
       "        [5.5, 3.5, 1.3, 0.2],\n",
       "        [4.9, 3.6, 1.4, 0.1],\n",
       "        [4.4, 3. , 1.3, 0.2],\n",
       "        [5.1, 3.4, 1.5, 0.2],\n",
       "        [5. , 3.5, 1.3, 0.3],\n",
       "        [4.5, 2.3, 1.3, 0.3],\n",
       "        [4.4, 3.2, 1.3, 0.2],\n",
       "        [5. , 3.5, 1.6, 0.6],\n",
       "        [5.1, 3.8, 1.9, 0.4],\n",
       "        [4.8, 3. , 1.4, 0.3],\n",
       "        [5.1, 3.8, 1.6, 0.2],\n",
       "        [4.6, 3.2, 1.4, 0.2],\n",
       "        [5.3, 3.7, 1.5, 0.2],\n",
       "        [5. , 3.3, 1.4, 0.2],\n",
       "        [7. , 3.2, 4.7, 1.4],\n",
       "        [6.4, 3.2, 4.5, 1.5],\n",
       "        [6.9, 3.1, 4.9, 1.5],\n",
       "        [5.5, 2.3, 4. , 1.3],\n",
       "        [6.5, 2.8, 4.6, 1.5],\n",
       "        [5.7, 2.8, 4.5, 1.3],\n",
       "        [6.3, 3.3, 4.7, 1.6],\n",
       "        [4.9, 2.4, 3.3, 1. ],\n",
       "        [6.6, 2.9, 4.6, 1.3],\n",
       "        [5.2, 2.7, 3.9, 1.4],\n",
       "        [5. , 2. , 3.5, 1. ],\n",
       "        [5.9, 3. , 4.2, 1.5],\n",
       "        [6. , 2.2, 4. , 1. ],\n",
       "        [6.1, 2.9, 4.7, 1.4],\n",
       "        [5.6, 2.9, 3.6, 1.3],\n",
       "        [6.7, 3.1, 4.4, 1.4],\n",
       "        [5.6, 3. , 4.5, 1.5],\n",
       "        [5.8, 2.7, 4.1, 1. ],\n",
       "        [6.2, 2.2, 4.5, 1.5],\n",
       "        [5.6, 2.5, 3.9, 1.1],\n",
       "        [5.9, 3.2, 4.8, 1.8],\n",
       "        [6.1, 2.8, 4. , 1.3],\n",
       "        [6.3, 2.5, 4.9, 1.5],\n",
       "        [6.1, 2.8, 4.7, 1.2],\n",
       "        [6.4, 2.9, 4.3, 1.3],\n",
       "        [6.6, 3. , 4.4, 1.4],\n",
       "        [6.8, 2.8, 4.8, 1.4],\n",
       "        [6.7, 3. , 5. , 1.7],\n",
       "        [6. , 2.9, 4.5, 1.5],\n",
       "        [5.7, 2.6, 3.5, 1. ],\n",
       "        [5.5, 2.4, 3.8, 1.1],\n",
       "        [5.5, 2.4, 3.7, 1. ],\n",
       "        [5.8, 2.7, 3.9, 1.2],\n",
       "        [6. , 2.7, 5.1, 1.6],\n",
       "        [5.4, 3. , 4.5, 1.5],\n",
       "        [6. , 3.4, 4.5, 1.6],\n",
       "        [6.7, 3.1, 4.7, 1.5],\n",
       "        [6.3, 2.3, 4.4, 1.3],\n",
       "        [5.6, 3. , 4.1, 1.3],\n",
       "        [5.5, 2.5, 4. , 1.3],\n",
       "        [5.5, 2.6, 4.4, 1.2],\n",
       "        [6.1, 3. , 4.6, 1.4],\n",
       "        [5.8, 2.6, 4. , 1.2],\n",
       "        [5. , 2.3, 3.3, 1. ],\n",
       "        [5.6, 2.7, 4.2, 1.3],\n",
       "        [5.7, 3. , 4.2, 1.2],\n",
       "        [5.7, 2.9, 4.2, 1.3],\n",
       "        [6.2, 2.9, 4.3, 1.3],\n",
       "        [5.1, 2.5, 3. , 1.1],\n",
       "        [5.7, 2.8, 4.1, 1.3],\n",
       "        [6.3, 3.3, 6. , 2.5],\n",
       "        [5.8, 2.7, 5.1, 1.9],\n",
       "        [7.1, 3. , 5.9, 2.1],\n",
       "        [6.3, 2.9, 5.6, 1.8],\n",
       "        [6.5, 3. , 5.8, 2.2],\n",
       "        [7.6, 3. , 6.6, 2.1],\n",
       "        [4.9, 2.5, 4.5, 1.7],\n",
       "        [7.3, 2.9, 6.3, 1.8],\n",
       "        [6.7, 2.5, 5.8, 1.8],\n",
       "        [7.2, 3.6, 6.1, 2.5],\n",
       "        [6.5, 3.2, 5.1, 2. ],\n",
       "        [6.4, 2.7, 5.3, 1.9],\n",
       "        [6.8, 3. , 5.5, 2.1],\n",
       "        [5.7, 2.5, 5. , 2. ],\n",
       "        [5.8, 2.8, 5.1, 2.4],\n",
       "        [6.4, 3.2, 5.3, 2.3],\n",
       "        [6.5, 3. , 5.5, 1.8],\n",
       "        [7.7, 3.8, 6.7, 2.2],\n",
       "        [7.7, 2.6, 6.9, 2.3],\n",
       "        [6. , 2.2, 5. , 1.5],\n",
       "        [6.9, 3.2, 5.7, 2.3],\n",
       "        [5.6, 2.8, 4.9, 2. ],\n",
       "        [7.7, 2.8, 6.7, 2. ],\n",
       "        [6.3, 2.7, 4.9, 1.8],\n",
       "        [6.7, 3.3, 5.7, 2.1],\n",
       "        [7.2, 3.2, 6. , 1.8],\n",
       "        [6.2, 2.8, 4.8, 1.8],\n",
       "        [6.1, 3. , 4.9, 1.8],\n",
       "        [6.4, 2.8, 5.6, 2.1],\n",
       "        [7.2, 3. , 5.8, 1.6],\n",
       "        [7.4, 2.8, 6.1, 1.9],\n",
       "        [7.9, 3.8, 6.4, 2. ],\n",
       "        [6.4, 2.8, 5.6, 2.2],\n",
       "        [6.3, 2.8, 5.1, 1.5],\n",
       "        [6.1, 2.6, 5.6, 1.4],\n",
       "        [7.7, 3. , 6.1, 2.3],\n",
       "        [6.3, 3.4, 5.6, 2.4],\n",
       "        [6.4, 3.1, 5.5, 1.8],\n",
       "        [6. , 3. , 4.8, 1.8],\n",
       "        [6.9, 3.1, 5.4, 2.1],\n",
       "        [6.7, 3.1, 5.6, 2.4],\n",
       "        [6.9, 3.1, 5.1, 2.3],\n",
       "        [5.8, 2.7, 5.1, 1.9],\n",
       "        [6.8, 3.2, 5.9, 2.3],\n",
       "        [6.7, 3.3, 5.7, 2.5],\n",
       "        [6.7, 3. , 5.2, 2.3],\n",
       "        [6.3, 2.5, 5. , 1.9],\n",
       "        [6.5, 3. , 5.2, 2. ],\n",
       "        [6.2, 3.4, 5.4, 2.3],\n",
       "        [5.9, 3. , 5.1, 1.8]]),\n",
       " 'target': array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "        0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),\n",
       " 'target_names': array(['setosa', 'versicolor', 'virginica'], dtype='<U10'),\n",
       " 'DESCR': '.. _iris_dataset:\\n\\nIris plants dataset\\n--------------------\\n\\n**Data Set Characteristics:**\\n\\n    :Number of Instances: 150 (50 in each of three classes)\\n    :Number of Attributes: 4 numeric, predictive attributes and the class\\n    :Attribute Information:\\n        - sepal length in cm\\n        - sepal width in cm\\n        - petal length in cm\\n        - petal width in cm\\n        - class:\\n                - Iris-Setosa\\n                - Iris-Versicolour\\n                - Iris-Virginica\\n                \\n    :Summary Statistics:\\n\\n    ============== ==== ==== ======= ===== ====================\\n                    Min  Max   Mean    SD   Class Correlation\\n    ============== ==== ==== ======= ===== ====================\\n    sepal length:   4.3  7.9   5.84   0.83    0.7826\\n    sepal width:    2.0  4.4   3.05   0.43   -0.4194\\n    petal length:   1.0  6.9   3.76   1.76    0.9490  (high!)\\n    petal width:    0.1  2.5   1.20   0.76    0.9565  (high!)\\n    ============== ==== ==== ======= ===== ====================\\n\\n    :Missing Attribute Values: None\\n    :Class Distribution: 33.3% for each of 3 classes.\\n    :Creator: R.A. Fisher\\n    :Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)\\n    :Date: July, 1988\\n\\nThe famous Iris database, first used by Sir R.A. Fisher. The dataset is taken\\nfrom Fisher\\'s paper. Note that it\\'s the same as in R, but not as in the UCI\\nMachine Learning Repository, which has two wrong data points.\\n\\nThis is perhaps the best known database to be found in the\\npattern recognition literature.  Fisher\\'s paper is a classic in the field and\\nis referenced frequently to this day.  (See Duda & Hart, for example.)  The\\ndata set contains 3 classes of 50 instances each, where each class refers to a\\ntype of iris plant.  One class is linearly separable from the other 2; the\\nlatter are NOT linearly separable from each other.\\n\\n.. topic:: References\\n\\n   - Fisher, R.A. \"The use of multiple measurements in taxonomic problems\"\\n     Annual Eugenics, 7, Part II, 179-188 (1936); also in \"Contributions to\\n     Mathematical Statistics\" (John Wiley, NY, 1950).\\n   - Duda, R.O., & Hart, P.E. (1973) Pattern Classification and Scene Analysis.\\n     (Q327.D83) John Wiley & Sons.  ISBN 0-471-22361-1.  See page 218.\\n   - Dasarathy, B.V. (1980) \"Nosing Around the Neighborhood: A New System\\n     Structure and Classification Rule for Recognition in Partially Exposed\\n     Environments\".  IEEE Transactions on Pattern Analysis and Machine\\n     Intelligence, Vol. PAMI-2, No. 1, 67-71.\\n   - Gates, G.W. (1972) \"The Reduced Nearest Neighbor Rule\".  IEEE Transactions\\n     on Information Theory, May 1972, 431-433.\\n   - See also: 1988 MLC Proceedings, 54-64.  Cheeseman et al\"s AUTOCLASS II\\n     conceptual clustering system finds 3 classes in the data.\\n   - Many, many more ...',\n",
       " 'feature_names': ['sepal length (cm)',\n",
       "  'sepal width (cm)',\n",
       "  'petal length (cm)',\n",
       "  'petal width (cm)'],\n",
       " 'filename': 'F:\\\\opt\\\\Anaconda3\\\\lib\\\\site-packages\\\\sklearn\\\\datasets\\\\data\\\\iris.csv'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.datasets import load_iris\n",
    "\n",
    "data=load_iris()\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'data' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m x\u001b[38;5;241m=\u001b[39mdata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m      2\u001b[0m y\u001b[38;5;241m=\u001b[39mdata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtarget\u001b[39m\u001b[38;5;124m'\u001b[39m]\n",
      "\u001b[1;31mNameError\u001b[0m: name 'data' is not defined"
     ]
    }
   ],
   "source": [
    "x=data['data']\n",
    "y=data['target']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(105, 4)\n",
      "(45, 4)\n",
      "(105,)\n",
      "(45,)\n"
     ]
    }
   ],
   "source": [
    "print(x_train.shape)\n",
    "print(x_test.shape)\n",
    "print(y_train.shape)\n",
    "print(y_test.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### k近邻"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',\n",
       "                     metric_params=None, n_jobs=None, n_neighbors=3, p=2,\n",
       "                     weights='uniform')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "\n",
    "model=KNeighborsClassifier(n_neighbors=3)\n",
    "model.fit(x_train,y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 1, 0, 2, 0, 2, 0, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 0, 0, 2, 1,\n",
       "       0, 0, 2, 0, 0, 1, 1, 0, 2, 1, 0, 2, 2, 1, 0, 2, 1, 1, 2, 0, 2, 0,\n",
       "       0])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred=model.predict(x_test)\n",
    "y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 1, 0, 2, 0, 2, 0, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 0, 0, 2, 1,\n",
       "       0, 0, 2, 0, 0, 1, 1, 0, 2, 1, 0, 2, 2, 1, 0, 1, 1, 1, 2, 0, 2, 0,\n",
       "       0])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict([[0.5,0.5,0.5,0.5]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9777777777777777"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.score(x_test,y_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、兵王问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>1</th>\n",
       "      <th>b</th>\n",
       "      <th>3</th>\n",
       "      <th>c</th>\n",
       "      <th>2</th>\n",
       "      <th>draw</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>a</td>\n",
       "      <td>1</td>\n",
       "      <td>c</td>\n",
       "      <td>1</td>\n",
       "      <td>c</td>\n",
       "      <td>2</td>\n",
       "      <td>draw</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>a</td>\n",
       "      <td>1</td>\n",
       "      <td>c</td>\n",
       "      <td>1</td>\n",
       "      <td>d</td>\n",
       "      <td>1</td>\n",
       "      <td>draw</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>a</td>\n",
       "      <td>1</td>\n",
       "      <td>c</td>\n",
       "      <td>1</td>\n",
       "      <td>d</td>\n",
       "      <td>2</td>\n",
       "      <td>draw</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>a</td>\n",
       "      <td>1</td>\n",
       "      <td>c</td>\n",
       "      <td>2</td>\n",
       "      <td>c</td>\n",
       "      <td>1</td>\n",
       "      <td>draw</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>a</td>\n",
       "      <td>1</td>\n",
       "      <td>c</td>\n",
       "      <td>2</td>\n",
       "      <td>c</td>\n",
       "      <td>3</td>\n",
       "      <td>draw</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28050</th>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>g</td>\n",
       "      <td>7</td>\n",
       "      <td>e</td>\n",
       "      <td>5</td>\n",
       "      <td>sixteen</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28051</th>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>g</td>\n",
       "      <td>7</td>\n",
       "      <td>e</td>\n",
       "      <td>6</td>\n",
       "      <td>sixteen</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28052</th>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>g</td>\n",
       "      <td>7</td>\n",
       "      <td>e</td>\n",
       "      <td>7</td>\n",
       "      <td>sixteen</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28053</th>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>g</td>\n",
       "      <td>7</td>\n",
       "      <td>f</td>\n",
       "      <td>5</td>\n",
       "      <td>sixteen</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28054</th>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>g</td>\n",
       "      <td>7</td>\n",
       "      <td>g</td>\n",
       "      <td>5</td>\n",
       "      <td>sixteen</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>28055 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       a  1  b  3  c  2     draw\n",
       "0      a  1  c  1  c  2     draw\n",
       "1      a  1  c  1  d  1     draw\n",
       "2      a  1  c  1  d  2     draw\n",
       "3      a  1  c  2  c  1     draw\n",
       "4      a  1  c  2  c  3     draw\n",
       "...   .. .. .. .. .. ..      ...\n",
       "28050  b  1  g  7  e  5  sixteen\n",
       "28051  b  1  g  7  e  6  sixteen\n",
       "28052  b  1  g  7  e  7  sixteen\n",
       "28053  b  1  g  7  f  5  sixteen\n",
       "28054  b  1  g  7  g  5  sixteen\n",
       "\n",
       "[28055 rows x 7 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chess=pd.read_csv('./data/SVM兵王问题/krkopt.data',sep=',')\n",
    "chess"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "x=chess.iloc[:,:6]\n",
    "y=chess.iloc[:,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>1</th>\n",
       "      <th>b</th>\n",
       "      <th>3</th>\n",
       "      <th>c</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28050</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28051</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28052</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28053</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28054</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>28055 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       a  1  b  3  c  2\n",
       "0      1  1  3  1  3  2\n",
       "1      1  1  3  1  4  1\n",
       "2      1  1  3  1  4  2\n",
       "3      1  1  3  2  3  1\n",
       "4      1  1  3  2  3  3\n",
       "...   .. .. .. .. .. ..\n",
       "28050  2  1  7  7  5  5\n",
       "28051  2  1  7  7  5  6\n",
       "28052  2  1  7  7  5  7\n",
       "28053  2  1  7  7  6  5\n",
       "28054  2  1  7  7  7  5\n",
       "\n",
       "[28055 rows x 6 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# x.replace(['a','b','c','d','e','f','g','h'],range(1,9),inplace=True)\n",
    "x.replace([chr(i) for i in range(97,123)],range(1,27),inplace=True)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-2.251402</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>-0.672679</td>\n",
       "      <td>-1.538726</td>\n",
       "      <td>-0.877156</td>\n",
       "      <td>-1.090537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-2.251402</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>-0.672679</td>\n",
       "      <td>-1.538726</td>\n",
       "      <td>-0.444302</td>\n",
       "      <td>-1.535310</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-2.251402</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>-0.672679</td>\n",
       "      <td>-1.538726</td>\n",
       "      <td>-0.444302</td>\n",
       "      <td>-1.090537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-2.251402</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>-0.672679</td>\n",
       "      <td>-1.100649</td>\n",
       "      <td>-0.877156</td>\n",
       "      <td>-1.535310</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-2.251402</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>-0.672679</td>\n",
       "      <td>-1.100649</td>\n",
       "      <td>-0.877156</td>\n",
       "      <td>-0.645765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28050</th>\n",
       "      <td>-1.184025</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>1.067920</td>\n",
       "      <td>1.089734</td>\n",
       "      <td>-0.011448</td>\n",
       "      <td>0.243781</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28051</th>\n",
       "      <td>-1.184025</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>1.067920</td>\n",
       "      <td>1.089734</td>\n",
       "      <td>-0.011448</td>\n",
       "      <td>0.688554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28052</th>\n",
       "      <td>-1.184025</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>1.067920</td>\n",
       "      <td>1.089734</td>\n",
       "      <td>-0.011448</td>\n",
       "      <td>1.133326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28053</th>\n",
       "      <td>-1.184025</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>1.067920</td>\n",
       "      <td>1.089734</td>\n",
       "      <td>0.421406</td>\n",
       "      <td>0.243781</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28054</th>\n",
       "      <td>-1.184025</td>\n",
       "      <td>-0.921888</td>\n",
       "      <td>1.067920</td>\n",
       "      <td>1.089734</td>\n",
       "      <td>0.854260</td>\n",
       "      <td>0.243781</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>28055 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              0         1         2         3         4         5\n",
       "0     -2.251402 -0.921888 -0.672679 -1.538726 -0.877156 -1.090537\n",
       "1     -2.251402 -0.921888 -0.672679 -1.538726 -0.444302 -1.535310\n",
       "2     -2.251402 -0.921888 -0.672679 -1.538726 -0.444302 -1.090537\n",
       "3     -2.251402 -0.921888 -0.672679 -1.100649 -0.877156 -1.535310\n",
       "4     -2.251402 -0.921888 -0.672679 -1.100649 -0.877156 -0.645765\n",
       "...         ...       ...       ...       ...       ...       ...\n",
       "28050 -1.184025 -0.921888  1.067920  1.089734 -0.011448  0.243781\n",
       "28051 -1.184025 -0.921888  1.067920  1.089734 -0.011448  0.688554\n",
       "28052 -1.184025 -0.921888  1.067920  1.089734 -0.011448  1.133326\n",
       "28053 -1.184025 -0.921888  1.067920  1.089734  0.421406  0.243781\n",
       "28054 -1.184025 -0.921888  1.067920  1.089734  0.854260  0.243781\n",
       "\n",
       "[28055 rows x 6 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn import preprocessing\n",
    "\n",
    "standard_scaler=preprocessing.StandardScaler()\n",
    "x=pd.DataFrame(standard_scaler.fit_transform(x))\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0        1\n",
       "1        1\n",
       "2        1\n",
       "3        1\n",
       "4        1\n",
       "        ..\n",
       "28050   -1\n",
       "28051   -1\n",
       "28052   -1\n",
       "28053   -1\n",
       "28054   -1\n",
       "Name: draw, Length: 28055, dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y=y.apply(lambda str:1 if str=='draw' else -1)\n",
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "training set: (3927, 6)\n",
      "validation set: (1684, 6)\n",
      "testing set: (22444, 6)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "x_trainval,x_test,y_trainval,y_test = train_test_split(x,y,test_size=0.8)\n",
    "x_train,x_val,y_train,y_val = train_test_split(x_trainval,y_trainval,train_size=0.7)\n",
    "\n",
    "print('training set:',x_train.shape)\n",
    "print('validation set:',x_val.shape)\n",
    "print('testing set:',x_test.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### svm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "test_score: 0.9917572625200499\n",
      "best_parameters: {'gamma': 0.1, 'C': 100}\n"
     ]
    }
   ],
   "source": [
    "from sklearn.svm import SVC\n",
    "\n",
    "best_score=0.0\n",
    "for gamma in [0.001, 0.01, 0.1, 1, 10, 100]:\n",
    "    for C in [0.001, 0.01, 0.1, 1, 10, 100]:\n",
    "        svm=SVC(gamma=gamma, C=C)\n",
    "        svm.fit(x_train,y_train)\n",
    "        score=svm.score(x_val,y_val)\n",
    "        if score>best_score:\n",
    "            best_score=score\n",
    "            best_parameters={'gamma':gamma,'C':C}\n",
    "            \n",
    "svm=SVC(**best_parameters)\n",
    "svm.fit(x_train,y_train)\n",
    "print('test_score:',svm.score(x_test,y_test))\n",
    "print('best_parameters:',best_parameters)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "precision_score: 0.9409991386735572\n",
      "recall_score: 0.9785042543663234\n",
      "f1_score: 0.9593852908891328\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import precision_score,recall_score,f1_score\n",
    "\n",
    "y_pred=svm.predict(x_test)\n",
    "print('precision_score:',precision_score(y_test,y_pred))\n",
    "print('recall_score:',recall_score(y_test,y_pred))\n",
    "print('f1_score:',f1_score(y_test,y_pred))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-10.81177158  -4.74790112 -24.10254294 ... -27.46699114   0.94478553\n",
      "  -6.30811925]\n",
      "auc: 0.998659750913133\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYA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sYc8xuBP0vyL+kdInntUv7HLslN9A7treqf97gG+D6AqnobvfMglwLTwFeBXz7hfS7h75ckaQEsx0NDkqRjYBBIUuMMAklqnEEgSY0zCCSpccvu8lFpUpJ8C/j0wKqXAxuAW+hdu38KsKuqfnfy1UnjMwik4/e1qjpvcEX/I81vq6qfT/IDwN1JPlhVdy5GgdI4PDQkdaSqvgLcCfzQYtcizccgkI7f05Lc3f/6y+GNSc6k9xlHByZfmjQ+Dw1Jx2/WoaG+n0xyF/Bt4D9VlUGgpzSDQFp4t1XVzy92EdK4PDQkSY0zCCSpcX76qCQ1zhmBJDXOIJCkxhkEktQ4g0CSGmcQSFLjDAJJapxBIEmN+/85Pze6Fa94+wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.metrics import roc_curve,auc\n",
    "\n",
    "y_score=svm.decision_function(x_test)\n",
    "print(y_score)\n",
    "\n",
    "fpr,tpr,threshold=roc_curve(y_test,y_score)\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plt.plot(fpr,tpr)\n",
    "plt.xlabel('FP')\n",
    "plt.ylabel('TP')\n",
    "plt.title('ROC Curve')\n",
    "\n",
    "print('auc:',auc(fpr,tpr))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3、信贷数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "data=pd.read_excel('./data/信贷数据审批/bankloan.xls')\n",
    "\n",
    "x=data.iloc[:,:-1]\n",
    "y=data.iloc[:,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 逻辑回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "逻辑回归模型在测试集上的准确率：\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.8285714285714286"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "\n",
    "LR=LogisticRegression()\n",
    "LR.fit(x_train,y_train)\n",
    "print('逻辑回归模型在测试集上的准确率：')\n",
    "LR.score(x_test,y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0,\n",
       "       0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,\n",
       "       0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,\n",
       "       1, 0, 1, 1, 0, 0, 1, 0], dtype=int64)"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LR.predict(x_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 朴素贝叶斯"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "朴素贝叶斯在测试集上的准确率：\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.7785714285714286"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.naive_bayes import GaussianNB, BernoulliNB, MultinomialNB\n",
    "\n",
    "gnb=GaussianNB()\n",
    "gnb.fit(x_train,y_train)\n",
    "print('朴素贝叶斯在测试集上的准确率：')\n",
    "gnb.score(x_test,y_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 决策树"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfUAAAGACAYAAAC0p/tjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdd5gV9dnG8e+zBRZhQUBYQKqCUsWygN0lKrFgwwaxYSMaTUx5UyzRmKgxRqPRWII0sWGJXaPYFkVFBYFIs2FDmiwgsLQtz/vHzOJh3WUpe86ccn+uay9OmTnn+R1g7zPP/GbG3B0RERFJfVlRFyAiIiL1Q6EuIiKSJhTqIiIiaUKhLiIikiYU6iIiImlCoS4iW2RmTer59ayGx3Lq8z0SKZVrl/SjUJeMY2Z5NQVLtWVyzKxe/n+Y2bVmdsoWnh9rZsfG3Dczm2hme9Wy/Iba6g9f65iY+4ea2e47UPsg4MXtXb8W+5vZy9Uem2Rm+9ZSwzQz2zPm/tNm1tXMLjez86otu1P1kDWzBjG3O5jZ1Jj7Vm3ZcWbW3sz+ZWaFWzmeP5rZzVuzoJldY2ZnbuXrimwzfc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JJ5zA008/zZgxY+jTpw8bN25k//3353e/+x3XXnstY8eOZcCAAXzwwQf8/e9/Z+nSpaxcuZLhw4ezceNG/vSnP7HHHnvw4IMP8tprr1FSUkJFRQXLli3juOOO2/RexcXF0Q1URESShkI9Tg4//HCaNm1Kw4YNqayspKKigqeffpo99tiDnJwcysrKmD59OpdeeiknnHACr7zyCqeccgoPPPAAbdu23fQ6U6dO5cYbb6RXr14MHjyY1atX85///IfBgwdTXl7OiSeeGOEoRUQkmaR9qF/77GzmLFxVr6/Zs11TrjmuV63Pjxw5kmeffZYjjjiCfv36bXo8dvLahAkTKCkpYciQIZx00kkccsghLF26lEGDBnHTTTdx9NFHA9C7d28mTJjAcccdx+TJk9mwYQMlJSVMnjyZsrIyOnToQPfu3et1fCIiUn+q5kMlQtqHehRGjBhBz549mThxIgDr1q0jJ2fzj/rss8/mqKOO4oYbbuDSSy9l4cKFnHDCCbz++uvk5uZSXl5OTk4OeXl5NGzYkA4dOnDEEUewevVqFi5cyBFHHAHAxo0bEz4+ERHZshWlG3lt3lImzlnMN0s2MHBgYt437UN9S1vU8ZaVFcxDnD9/PieffPJmz5kZN998M7/+9a+ZNWsWs2bNYubMmcyfP5+nnnqK/Px8nnzySZo0aUKjRo046aST6N27N2+++SZDhgyhd+/eADpjnIhIkliwYi0vz1nCxNlLeO+L5VRUOm2a5tF7Z8PdE3KocdqHepS+++47XnvtNT7++GO6deu22XMfffQRH330EePHj+fwww9n9OjRPP300yxbtoyCggJyc3Np0qQJs2bN4mc/+xlZWVnceeedrFy5kuzsbMaMGUOXLl0oKyvjjjvuYN99941olCIimcndmbd4NRNnL2HinMXMDnf17lHQhIsP251BvQros2szJk2alLBzhyjU42TDhg2MHTuWNm3a0KtX0C0oKysDgn8IHTp04IYbbuDll1/mpZde4t577+Xyyy/njTfeYNddd+Wmm26ib9++9OnTh/vvv58JEyYwY8YMioqKMDNmzZrFunXrGDZsmPapi4gkSEWlM/WL5UycEwT518vXYQb7dWzOFcd058iebeiyS+PI6lOox8myZcu48cYbmT59Otdccw0At91226bZ8JMnT2bmzJmce+65vP/++xx33HEsXryYBx98kFNPPZVbb72VuXPn0rhxY0aMGMFFF13E7373O8aNG0dpaSm333478+bN495776VFixbsvffeEY9YRCQ9rS+r4M1PljFx9mJenbeU5aUbaZCdxcHdduGSoq4c3qOAVvkNoy4TUKjHzemnn/6Dxxo1agTA3XffDcAZZ5wBQI8ePQAoLS3l0EMPpVWrVgD06dMHgFdeeWXTa5x77rmbbnfv3p1bbrklDtWLiGS22Ilub3y8jHVlFeTn5XB499YM6tWGQ/doRZOGyRehyVdRBmvcuDGVlZVRlyEikpFqm+h2amF7BvVsQ/8uLWiQk9wnYlWoi4hIRtraiW6pdIEshbqIiGSM8opKpn25Imknuu0ohbqIiKS1VJrotqMU6nGyevVq8vPza3xu/vz5NG/enObNm//guaVLl5Kfn/+DExWsXLmSZs2CNtDSpUtp3bp13GoXEUkHazaUc9/bX3Dvm/NZubYsJSa67ajk3uOfotasWcMRRxxBcXExp556KsOHD+f0009n+vTpAIwZM4YPPviAK6644geneT355JN5/vnnueyyyzZ7XJdeFRHZOms2lHPn659y8N9e4+8vfcS+HZsz/rz+TLvqSG4bug/H9GmbloEO2lKPiyZNmvDCCy+wYsUKsrOzuf7663nwwQdZtmwZgwYN4sADDyQ7O5s999yTu+++m0suuWTTueEbN27MscceyxdffEFZWRm5ubm69KqIyFaovmX+o+6tuezwbvTtsHPUpSVM+of6f/8Aiz+s39ds0weOvrHWp6dMmcKKFSs2XWntoosuok+fPuTm5tKgQYNNy51zzjmsWrWKoqIi8vLyAJgzZw5HHHEEFRUVHHPMMZSUlOjSqyIiW6Aw/176h3oEevXqxZAhQ+jatSsA2dnZNG3adLNlPvvsM37/+99z+eWXM2nSJLKysigrK+OYY47hueee2xTybdu21aVXRURqoDD/ofQP9S1sUcdLfn4+zzzzDDk5Obg7ZWVlm25X2X333bn44ospKytj9OjRXH311ey7777suuuuLFiwYNMXAl16VURkcwrz2qV/qEfk6aef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sV5ieBdba3tfMm2T5Cvdb2LfUq20ZJr7Yl/zuAASrU35b0uaR7xujWRHRWXmmLiP8k/39H/H8k1CMiIjoiy+8REREdkVCPiIjoiIR6RERERyTUIyIiOuJPzXEcaPE9PfoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.tree import DecisionTreeClassifier\n",
    "\n",
    "depths=range(1,15)\n",
    "train_score_list=[]\n",
    "test_score_list=[]\n",
    "\n",
    "for d in depths:\n",
    "    dtc=DecisionTreeClassifier(criterion='entropy',max_depth=d)\n",
    "    dtc.fit(x_train,y_train)\n",
    "    train_score_list.append(dtc.score(x_train,y_train))\n",
    "    test_score_list.append(dtc.score(x_test,y_test))\n",
    "    \n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plt.rcParams['font.family']='SimHei'\n",
    "\n",
    "plt.figure(figsize=(8,6))\n",
    "plt.plot(depths,train_score_list)\n",
    "plt.plot(depths,test_score_list)\n",
    "plt.legend(['训练集','测试集'])\n",
    "plt.xlabel('决策树深度')\n",
    "plt.ylabel('准确率')\n",
    "plt.title('不同决策树深度下的模型准确率')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- ID3：信息增益\n",
    "- C4.5：信息增益比\n",
    "- CART：基尼系数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn import tree\n",
    "import pydotplus\n",
    "\n",
    "import os     \n",
    "os.environ[\"PATH\"] += os.pathsep + 'D:\\Program Files (x86)\\Graphviz2.38/bin/'\n",
    "\n",
    "\n",
    "clf=tree.DecisionTreeClassifier(criterion=\"entropy\",max_depth=5)\n",
    "clf.fit(x_train,y_train)\n",
    "\n",
    "with open(\"./data/信贷数据审批/bankloanTree.dot\",\"w\") as fw:\n",
    "    tree.export_graphviz(clf,out_file=fw)\n",
    "\n",
    "dot_data = tree.export_graphviz(clf, out_file=None,\n",
    "                                feature_names=data.columns[0:-1],\n",
    "                                class_names=['不违约', '违约'],\n",
    "                                filled=True, rounded=True,\n",
    "                                special_characters=True)\n",
    "graph = pydotplus.graph_from_dot_data(dot_data.replace(\"helvetica\",\"FangSong\").encode(encoding='utf-8'))\n",
    "graph.write_png(\"./data/信贷数据审批/bankloanTree.png\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
